<%@ page language="java" contentType="text/html; charset=utf8"
    pageEncoding="utf8"%>
<%
  String xm = this.getServletContext().getInitParameter("path");
	String path1 = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/"+xm;
%>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>菜单列表</title>


<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="<%=path1%>/qt/yjs/jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="<%=path1%>/qt/yjs/bootstrap.min.js"></script>
    


<link href="<%=path1%>/css/css.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/redmond/jquery-ui-1.8.2.custom.css"/>
<link type="text/css" rel="stylesheet" href="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/ui.jqgrid.css"/>  


<script type="text/javascript" src="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/jquery.jqGrid.src.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/jquery.jqGrid.min.js"></script>  
<link rel="stylesheet" href="<%=path1%>/qt/ycss/bootstrap.min.css">

<!-- 可选的Bootstrap主题文件（一般不用引入） -->
<link rel="stylesheet" href="ycss/bootstrap-theme.min.css">
<script type="text/javascript">
$(document).ready(function(){
    $("#list4").jqGrid({
    	url:"<%=path1%>/qt/menu/selectAll.do",
        datatype:"json",  
        mtype:"POST",    
        height:320,  
        autowidth:true, 
       colNames:['菜单名称','menu_id','url','pid'],
       colModel:[ 
{name:'menu_name',index:'menu_name', width:'30%',align:'center'},                  
{name:'menu_id',index:'menu_id', width:'30%',align:'center',hidden:true},
{name:'menu_url',index:'menu_url', width:'30%',align:'center'},
{name:'pid',index:'pid', width:'30%',align:'center',hidden:true},
  ],
        multiselect:true,
        rownumbers:true,
        viewrecords: true,
        rowNum:100,
        rowList:[100,200,300],
        jsonReader:{
            id: "blackId",
            repeatitems : false
        },
        pager:$('#gridPager')
       
    });

});

</script>
<script type="text/javascript">
  

  function ajaxDelete(){  
      var menu_id=$('#list4').jqGrid('getGridParam','selrow');
      if(menu_id==null)
      	{
      	alert("请选择要删除的行");
      	return;
      	}
      var rowData = $('#list4').jqGrid('getRowData',menu_id);
      delid=rowData.menu_id;
        

      $.ajax({  
      data: {menu_id:delid},  
      type:"Post",  
      dataType: 'json',  
       url:"<%=path1%>/qt/menu/deleteMenu.do",  
       error:function(data){  
           alert("出错了！！");  
       },  
      success:function(data){  
      	$("#list4").jqGrid('setGridParam',{ 
              datatype:'json', 
              postData:{'pageSize':10,'pageIndex':1,'SearchSql':""}, // 发送数据   
              page:1 
          }).trigger("reloadGrid"); 
      	 //alert("success:"+data.msg);  
          // $("#result").html(data.msg) ;  
       }  
       });  
   } 
  
  
  function ajaxUpdate(){    	
  	var menu_id=$('#list4').jqGrid('getGridParam','selrow');
  
  	if(menu_id==null)
  	{
  	alert("请选择要修改的行");
  	return;
  	}else
  	{
 		 $('#myModal').modal('show');
 		 var rowData = $('#list4').jqGrid('getRowData',menu_id);
 		idd=rowData.menu_id;
 		 $("#menu_name").val(rowData.menu_name); 
 		$("#pid").val(rowData.pid); 
 		$("#menu_url").val(rowData.menu_url); 
 
      } 
 	}
  
  
</script>
</head>
<body>
 <table id="projectTable"></tab9le>
  
    <div class="yboxwidth boxcenter ybox01">
<div class="ybox09">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
       <td style="padding-left: 20px"><table border="0" cellspacing="0" cellpadding="0">
          <tr valign="top" >
            <td class="ybox11td5" ></td>
            <td class="ybox11td6" >菜单信息列表</td>
            <td class="ybox11td7"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td4"></td>    
          </tr>
        </table></td>
        </tr>
    </table>
  </div>
  
  <div class="ybox02">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="margb4">
      <tr>
        <td class="ybox03td1"></td>
        <td class="ybox03td2"></td>
        <td class="ybox03td3"></td>
      </tr>
      <tr>
        <td class="ybox03td4"></td>
        <td class="ybox03td5"><div class="ybox05 margb8">
          <dl>
           
          </dl>
        </div>
        <script type="text/javascript">
        function ajaxInsert(){  
            window.location.href='addMenu.jsp';
           }
        </script>
        
        
          <div class="ybox07 margb2">
      <dl><table border="0" cellspacing="0" cellpadding="0" class="ybox07table" >
              <tr align="left">
                <td class="ybox07td1"><img src="images/op4_1.gif" /></td>
                <td><span style="cursor:pointer;" onclick="ajaxInsert()">添加菜单信息</span></td>
                <td class="ybox07td2"><img src="images/op4_0.gif" /></td>
                <td class="ybox07td1"><img src="images/op4_6.gif" /></td>
                <td><span style="cursor:pointer;" onclick="ajaxUpdate()">修改菜单信息</span></td>
                <td class="ybox07td2"><img src="images/op4_0.gif"  /></td>
                <td class="ybox07td1"><img src="images/op4_3.gif" /></td>
                <td><span style="cursor:pointer;" onclick="ajaxDelete()">移除菜单信息</span></td>
                <td class="ybox07td2" width="47%"><img src="images/op4_0.gif" /></td>
              
              </tr>
          </table>
          </dl>
          </div>
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="ybox06table" id="list4">        
          </table>
        
        <td class="ybox03td6"></td>
      </tr>
      <tr>
        <td class="ybox03td7"></td>
        <td class="ybox03td8"></td>
        <td class="ybox03td9"></td>
      </tr>
    </table>
  </div>
</div>
   
   
   <!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document">
    <div class="modal-content" style="background:#d3ebf8; ">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">修改</h4>
      </div>
      <div class="modal-body"　>



 <div class="form-group" >
    <label for="inputEmail3" class="col-sm-2 control-label">菜单名称</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="menu_name" placeholder="menu_name">
    </div>
  </div>
   <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">上级id</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="pid" placeholder="pid">
    </div>
  </div>
  
  
   <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">菜单地址</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="menu_url" placeholder="menu_url">
    </div>
  </div>
  
   <script>
   
   function ajaxUpdate123(){
	  
     $.ajax({ 	
     data: {
     	menu_id:idd,
     	menu_name:$("#menu_name").val(),
     	pid:$("#pid").val(),
     	menu_url:$("#menu_url").val()
     	},  
     	type:"Post",  
     dataType: 'json',  
     url:"menu/updateMenu.do", 
     error:function(data){  
          alert("修改出错了！！");  
     },  
     success:function(data){
     	alert('客户信息修改成功！');
     	window.location.href = 'listMenu.jsp'; 
       }  
      });  
  } 
   </script>

      </div>
       <div class="modal-footer">
        <input type="button" onclick="ajaxUpdate123()" value="　提　交" class="btn btn-success"/>
        <button type="button" class="btn btn-success">　取　消　</button>
      </div>
    </div>
  </div>
</div>
    
    
    
</body>
</html>